package com.wakyde.mapper;

import com.wakyde.pojo.User;
import org.mybatis.spring.SqlSessionTemplate;

import java.util.List;
import java.util.Map;

public class UserMapperImpl implements UserMapper {

    // 我们的所有操作，都使用sqlSession来执行，在原来，现在都使用SqlSessionTemplate
    private SqlSessionTemplate sqlSession;

    public void setSqlSession(SqlSessionTemplate sqlSession){
        this.sqlSession = sqlSession;
    }

    @Override
    public List<User> getUserList() {
        return null;
    }

    @Override
    public List<User> getUserByLimit(Map<String, Object> map) {
        return null;
    }

    @Override
    public List<User> getUserByRowBounds() {
        return null;
    }

    @Override
    public List<User> selectUser() {
        this.addUser(new User(9, "fsdfs", "sdfsdf"));
        this.deleteUser(9);
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        return mapper.selectUser();
    }

    @Override
    public int addUser(User user) {
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        return mapper.addUser(user);
    }

    @Override
    public int deleteUser(int id) {
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        return mapper.deleteUser(id);
    }


}
